﻿

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GenerateCode_GEBrilliantFactory
{
    /// <summary>
    /// 生成查询实体类
    /// </summary>
    public class InputModel_Generate : BaseGenerate
    {
        public static string CreateQueryModelLText(string Modulelogo,
            string ChinaComment, List<ColumnModel> columnNameList, string entityName)
        {
            var str = TextHelper.ReadText(@"Templete\Entity\InputModel模板.txt");
            CommonReplace(ref str);

            str = str.Replace("$ChinaComment$", ChinaComment);//中文注释
            str = str.Replace("$EntityName$", entityName);

            str = str.Replace("$Modulelogo$", Modulelogo);//模块简写

            //处理 分页查询部分
            string attrString = "";

            List<ColumnModel> newColumnNameList = ListHelper.OnlyRemoveId(columnNameList);
            for (int i = 0; i < newColumnNameList.Count; ++i)
            {
                attrString += StructStrHelper.GenerateAttributeForQueryModel(newColumnNameList[i]);
                attrString += StructStrHelper.GenerateAttributeForQueryModelMode(newColumnNameList[i]);
            }
            str = str.Replace("$QueryAttributes$", attrString);

            //处理 新增部分
            attrString = "";
            newColumnNameList = ListHelper.RemoveIdCreatorModifier(columnNameList);
            for (int i = 0; i < newColumnNameList.Count; ++i)
            {
                attrString += StructStrHelper.GenerateAttribute(i,newColumnNameList[i]);
            }
            str = str.Replace("$AddAttributes$", attrString);

            return str;
        }
    }
}
